<?php


/**
 * @package Spider Contacts
 * @author Web-Dorado
 * @copyright (C) 2012 Web-Dorado. All rights reserved.
 * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 **/
defined('_JEXEC') or die('Restricted access');



$prod_iterator = 0;

$rows = $this->rows;

$option = $this->option;

$params = $this->params;

$page_num = $this->page_num;

$cont_count = $this->cont_count;

$cont_in_page = $this->cont_in_page;

$categories = $this->categories;

$category_list = $this->category_list;

$param_categories = $this->param_categories;





if ($params->get('cube_radius')):
?>
<style type="text/css">
#contactMainDivCube, .spidercontactbutton, .spidercontactinput
{
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
}

#contactMainDivCube #contTitle
{
-webkit-border-top-right-radius: 8px;
-webkit-border-top-left-radius: 8px;
-moz-border-radius-topright: 8px;
-moz-border-radius-topleft: 8px;
border-top-right-radius: 8px;
border-top-left-radius: 8px;
}
</style>
<?php
endif;
$cat_id = JRequest::getVar('cat_id', 0);



 
  
if (($params->get("choose_category") and !($param_categories > 0)) or $params->get("name_search"))
  {
    echo '<form action="" method="post" name="cat_form">
<input type="hidden" name="page_num"	value="1">
<div class="ContactSearchBox">';

if ($params->get("choose_category") and !($param_categories > 0))
{
	
	echo JText::_('SH_CHOOSE_CATEGORY') . '&nbsp;
	<select id="cat_id" name="cat_id" class="spidercontactinput" size="1" onChange="document.cat_form.submit();">
		<option value="0">' . JText::_('SH_ALL') . '</option> ';
    
    foreach ($category_list as $category)
    {
        if ($category->id == $cat_id)
            echo '<option value="' . $category->id . '"  selected="selected">' . $category->name . '</option>';
        
        else
            echo '<option value="' . $category->id . '" >' . $category->name . '</option>';
    }
        
    echo '</select>';
}

if ( $params->get("name_search"))
{
$name_search = JRequest::getVar('name_search', '');
echo '<br />
' . JText::_('SH_SEARCH') . '&nbsp;
<input id="name_search" name="name_search" class="input" value="'.$name_search.'"> 
	<input type="submit" value="'. JText::_('SH_GO') .'" class="spidercontactbutton" style="background-color:'.$params->get( 'cube_button_background_color' ).'; color:'.$params->get( 'cube_button_color' ).'; width:inherit;"><input type="button" value="'. JText::_('SH_RESET') .'" onClick="cat_form_reset(this.form);" class="spidercontactbutton" style="background-color:'.$params->get( 'cube_button_background_color' ).'; color:'.$params->get( 'cube_button_color' ).'; width:inherit;">';
}
echo '</div></form>';
}

    
  
  
  
  
  
  
    ?>
    <table border="0" cellpadding="0" cellspacing="0" id="contactMainTable">
    <tr>
      <?php
	  
    
foreach ($rows as $row)
  {
    if (($prod_iterator % $params->get('cube_count_of_contact_in_the_row')) === 0 and $prod_iterator > 0)
        echo "</tr><tr>";
    
    
    
    $prod_iterator++;
    
    
    
    $link = JRoute::_('index.php?option=' . $option . '&contact_id=' . $row->id . '&view=showcontact&page_num=' . $page_num . '&back=1');
    
    	
    
    $imgurl = explode(";", $row->image_url);
    echo '<td><div id="contactMainDivCube" style="' .'  border-width:' . $params->get('cube_border_width') . 'px;border-color:' . $params->get('cube_border_color') . ';border-style:' . $params->get('cube_border_style') . ';' . (($params->get('cube_text_size_small') != '') ? ('font-size:' . $params->get('cube_text_size_small') . 'px;') : '') . (($params->get('cube_text_color') != '') ? ('color:' . $params->get('cube_text_color') . ';') : '') . (($params->get('cube_background_color') != '') ? ('background-color:' . $params->get('cube_background_color') . ';') : '') .' width:' . $params->get('cube_contact_cell_width') . 'px; height:' . $params->get('cube_contact_cell_height') . 'px; ">




<div style="height:' . ((int)$params->get('cube_contact_cell_height')-20). 'px;" >

<div id="contTitle" style="font-size:' . $params->get('cube_title_size_small') . 'px;' . (($params->get('cube_title_color') != '') ? ('color:' . $params->get('cube_title_color') . ';') : '') . (($params->get('cube_title_background_color') != '') ? ('background-color:' . $params->get('cube_title_background_color') . ';') : '') . '">' . $row->first_name.' '.$row->last_name.'</div>



<table id="contMiddle" border="0" cellspacing="0" cellpadding="0"><tr>';
    
    
     if (!($row->image_url != "" and $row->image_url != ";"))
      {
        $imgurl[0] = "components/com_spidercontacts/images/noimage.jpg";
        
  echo '<td style="padding:10px;"><img src="index.php?option=com_spidercontacts&view=picture&format=raw&tmpl=component&url=' . $imgurl[0] . '&width=' . $params->get('cube_small_picture_width') . '&height=' . $params->get('cube_small_picture_height') . '" />

</td>';
      }
    else
	{
        echo '<td style="padding:10px;"><a href="' . $imgurl[0] . '" target="_blank"><img src="index.php?option=com_spidercontacts&view=picture&format=raw&tmpl=component&url=' . $imgurl[0] . '&width=' . $params->get('cube_small_picture_width') . '&height=' . $params->get('cube_small_picture_height') . '" /></a></td>';
          
	  
  
   
echo '</td><td></td></tr>';


  }

	echo '</td></tr>

</table>


</div>


<div style="float:right;" id="contMore"><a href="' . $link . '" style="' . (($params->get('cube_hyperlink_color') != '') ? ('color:' . $params->get('cube_hyperlink_color') . ';') : '') . '">' . JText::_('SH_MORE_INFO') . '</a></div></td>';
    
    
    
  }

?>

</tr>
</table>
  
            <div id="spidercontactnavigation" style="text-align:center;">

    <?php



$pos = strpos($_SERVER['QUERY_STRING'], "page_num") - 1;



if ($pos > 0)
    $url = substr($_SERVER['QUERY_STRING'], 0, $pos);

else
    $url = $_SERVER['QUERY_STRING'];





$pos = strpos($_SERVER['QUERY_STRING'], "cat_id") - 1;



if ($pos > 0)
    $url = substr($url, 0, $pos);





if ($cat_id != 0)
    $url .= "&cat_id=" . $cat_id;







if ($cont_count > $cont_in_page and $cont_in_page > 0)
  {
    $r = ceil($cont_count / $cont_in_page);
    
    
    
    
    
    $navstyle = (($params->get('cube_text_size_small') != '') ? ('font-size:' . $params->get('cube_text_size_small') . 'px;') : '') . (($params->get('cube_text_color') != '') ? ('color:' . $params->get('cube_text_color') . ';') : '');
    
    
    
    $link = JRoute::_('index.php?' . $url . '&page_num= ');
    
    if ($page_num > 5)
      {
        $link = JRoute::_('index.php?' . $url . '&page_num=1');
        
        echo "

&nbsp;&nbsp;<a href=\"$link\" style=\"$navstyle\">first</a>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;...&nbsp";
        
      }
	   if ($page_num > 1)
      {
        $link = JRoute::_('index.php?' . $url . '&page_num=' . ($page_num - 1));
        
        echo "&nbsp;&nbsp;<a href=\"$link\" style=\"$navstyle\">prev</a>&nbsp;&nbsp;";
        
      }
    
    
    
    for ($i = $page_num - 4; $i < ($page_num + 5); $i++)
      {
        if ($i <= $r and $i >= 1)
          {
            $link = JRoute::_('index.php?' . $url . '&page_num=' . $i);
            
            if ($i == $page_num)
                echo "<span style='font-weight:bold;color:#000000'>&nbsp;$i&nbsp;</span>";
            
            else
                echo "<a href=\"$link\" style=\"$navstyle\">&nbsp;$i&nbsp;</a>";
            
          }
        
      }
    
    
    
    
    
    if ($page_num < $r)
      {
        $link = JRoute::_('index.php?' . $url . '&page_num=' . ($page_num + 1));
        
        echo "&nbsp;&nbsp;<a href=\"$link\" style=\"$navstyle\">next</a>&nbsp;&nbsp;";
        
      }
    
    if (($r - $page_num) > 4)
      {
        $link = JRoute::_('index.php?' . $url . '&page_num=' . $r);
        
        echo "&nbsp;...&nbsp;&nbsp;&nbsp;<a href=\"$link\" style=\"$navstyle\">last</a>";
        
      }
    
  }

?></div>
  
  
  
  
    
<script type="text/javascript">
var SpiderCatOFOnLoad = window.onload;
window.onload = SpiderCatAddToOnload;
</script>
  
  

  